import request from '@/utils/request'

// 订单结算
// mode: cart    => obj { cartIds }
// mode: buyNow  => obj { goodsId  goodsNum  goodsSkuId }
export const checkOrder = (mode,obj) => {
    return request({
        method:'get',
        url:'/checkout/order',
        params:{
            mode:mode,  //cart:购物车购买  buyNow:立即购买
            delivery: 10, // 10 快递配送  20门店自取
            couponId: 0,  //优惠券id 0:不使用积分
            isUsePoints: 0, // 0:不使用积分
            ...obj  //将我们传递过来的参数动态展开
            // payType: 10, // 余额支付
        }
    })
}

// 提交订单
// mode: cart    => obj { cartIds,remark }
// mode: buyNow  => obj { goodsId  goodsNum  goodsSkuId,remark }
export const submitOrder = (mode,obj)=>{
    return request({
        method:'post',
        url:'/checked/submit',
        data:{
            mode:mode,
            delivery: 10, // 10 快递配送
            couponId: 0,
            isUsePoints: 0,
            payType: 10, // 余额支付
            ...obj
        }
    })
}

// 我的订单列表
export const getMyOrderList = (dataType,page)=>{
    return request({
        method:'get',
        url:'/order/list',
        params:{
            dataType,
            page  //可以使用vant中的list组件做分页
        }
    })
}